package org.fhm.zdte.common.standard;

import org.fhm.zdte.common.exception.ProtocolException;

import java.util.concurrent.TimeUnit;

/**
 * The interface <b>ISubCmd</b>'s implementation is used to manage Thread-State.
 *
 * @author 谭波
 * @since 2023/11/29
 */
public interface IThreadManager {

    /**
     * The thread waits for a certain amount of time.
     *
     * @param time Amount of time.
     * @param unit Units of time.
     * @param name Name of lock.
     * @return <b>true</b> indicates that blocking has succeeded, while <b>false</b> signifies that blocking has failed.
     */
    boolean waitForTime(int time, TimeUnit unit, String name) throws ProtocolException;

    /**
     * Let go of thread blocking.
     *
     * @param name Name of lock.
     * @return <b>ture</b> indicates that thread is successful to open, <b>false</b> indicates that thread is failed to open.
     */
    boolean notify(String name);

    /**
     * Open all threads.
     */
    void notifyAllLock();

}
